<template>
  <div class="receiveContent">
    <div class="receiveTitle">
      <div class="customerTitle">海川医药质管部验收{{ systemTime }}日报</div>
      <el-button type="success" @click="saveZlysdaily">保存</el-button>
    </div>
    <div class="qualitycheckheader">
      <div class="customText">类型</div>
      <div class="delivery">
        <div class="deliveryTop">验收</div>
        <div class="deliveryBottom">
          <div class="noOvertime">普药</div>
          <div class="Overtime">结束时间</div>
          <div class="noOvertime">中药</div>
          <div class="Overtime">结束时间</div>
          <div class="noOvertime">退货</div>
          <div class="Overtime">异常情况</div>
          <div class="Overtime">结束时间</div>
          <div class="noOvertime">京东验收</div>
          <div class="Overtime">异常情况</div>
          <div class="Overtime">结束时间</div>
        </div>
      </div>
    </div>
    <div class="customExtra">
      <div class="customText wyLayout">货主</div>
      <div class="customTextchild wyLayout">条目</div>
      <div class="customTextchild wyLayout">件数</div>
      <div class="overtime wyLayout">/</div>
      <div class="customTextchild wyLayout">条目</div>
      <div class="customTextchild wyLayout">件数</div>
      <div class="overtime wyLayout">/</div>
      <div class="customTextchild wyLayout">条目</div>
      <div class="customTextchild wyLayout">件数</div>
      <div class="customTextabnomal wyLayout">条目</div>
      <div class="overtime wyLayout">/</div>
      <div class="customTextchild wyLayout">品规数</div>
      <div class="customTextchild wyLayout">盒数</div>
      <div class="testReport wyLayout">条目</div>
      <div class="testReport wyLayout noborder">/</div>
    </div>
    <div class="customExtra">
      <div class="customText wyLayout">海通</div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatepytmTotal"
          v-model="reform.htPyTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatepyjsTotal"
          v-model="reform.htPyJs"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout endtimetop">
        <el-time-picker
          v-model="reform.htwyPyTime"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatezytmTotal"
          v-model="reform.htZyTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatezyjsTotal"
          v-model="reform.htZyJs"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout endtimetop">
        <el-time-picker
          v-model="reform.htwyZyTime"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatethtmTotal"
          v-model="reform.htThTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatethjsTotal"
          v-model="reform.htThJs"
          size="medium"
        />
      </div>
      <div class="customTextabnomal wyLayout">
        <el-input
          @input="calculateycqktmTotal"
          v-model="reform.htYcqkTm"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout endtimeCenter">
        <el-time-picker
          v-model="reform.thTime"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatejspgsTotal"
          v-model="reform.htJdysPgs"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatejdhsTotal"
          v-model="reform.htJdysHs"
          size="medium"
        />
      </div>
      <div class="testReport wyLayout">
        <el-input
          @input="calculatejdtmTotal"
          v-model="reform.htJdysTm"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout noborder endtimeCenter">
        <el-time-picker
          v-model="reform.jdTime"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
    </div>
    <div class="customExtra">
      <div class="customText wyLayout">伟业</div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatepytmTotal"
          v-model="reform.wyPyTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatepyjsTotal"
          v-model="reform.wyPyJs"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatezytmTotal"
          v-model="reform.wyZyTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatezyjsTotal"
          v-model="reform.wyZyJs"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatethtmTotal"
          v-model="reform.wyThTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatethjsTotal"
          v-model="reform.wyThJs"
          size="medium"
        />
      </div>
      <div class="customTextabnomal wyLayout">
        <el-input
          @input="calculateycqktmTotal"
          v-model="reform.wyYcqkTm"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatejspgsTotal"
          v-model="reform.wyJdysPgs"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatejdhsTotal"
          v-model="reform.wyJdysHs"
          size="medium"
        />
      </div>
      <div class="testReport wyLayout">
        <el-input
          @input="calculatejdtmTotal"
          v-model="reform.wyJdysTm"
          size="medium"
        />
      </div>
      <div class="testReport wyLayout noborder"></div>
    </div>
    <div class="customExtra">
      <div class="customText wyLayout">其他货主</div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatepytmTotal"
          v-model="reform.qtPyTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatepyjsTotal"
          v-model="reform.qtPyJs"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout">
        <el-time-picker
          v-model="reform.qtPyTime"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatezytmTotal"
          v-model="reform.qtZyTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatezyjsTotal"
          v-model="reform.qtZyJs"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout">
        <el-time-picker
          v-model="reform.qtZyTime"
          placeholder=""
          value-format="HH:mm"
          format="HH:mm"
        >
        </el-time-picker>
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatethtmTotal"
          v-model="reform.qtThTm"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatethjsTotal"
          v-model="reform.qtThJs"
          size="medium"
        />
      </div>
      <div class="customTextabnomal wyLayout">
        <el-input
          @input="calculateycqktmTotal"
          v-model="reform.qtYcqkTm"
          size="medium"
        />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatejspgsTotal"
          v-model="reform.qtJdysPgs"
          size="medium"
        />
      </div>
      <div class="customTextchild wyLayout">
        <el-input
          @input="calculatejdhsTotal"
          v-model="reform.qtJdysHs"
          size="medium"
        />
      </div>
      <div class="testReport wyLayout">
        <el-input
          @input="calculatejdtmTotal"
          v-model="reform.qtJdysTm"
          size="medium"
        />
      </div>
      <div class="testReport wyLayout noborder"></div>
    </div>
    <div class="customExtraHj">
      <div class="customText wyLayout">合计</div>
      <div class="customTextchild wyLayout">
        <el-input v-model="pytmTotal" size="medium" disabled />
      </div>
      <div class="customTextchild wyLayout">
        <el-input v-model="pyjsTotal" size="medium" disabled />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input v-model="zytmTotal" size="medium" disabled />
      </div>
      <div class="customTextchild wyLayout">
        <el-input v-model="zyjsTotal" size="medium" disabled />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input v-model="thtmTotal" size="medium" disabled />
      </div>
      <div class="customTextchild wyLayout">
        <el-input v-model="thjsTotal" size="medium" disabled />
      </div>
      <div class="customTextabnomal wyLayout">
        <el-input v-model="ycqktmTotal" size="medium" disabled />
      </div>
      <div class="overtime wyLayout"></div>
      <div class="customTextchild wyLayout">
        <el-input v-model="jdpgsTotal" size="medium" disabled />
      </div>
      <div class="customTextchild wyLayout">
        <el-input v-model="jdhsTotal" size="medium" disabled />
      </div>
      <div class="testReport wyLayout">
        <el-input v-model="jdtmTotal" size="medium" disabled />
      </div>
      <div class="testReport wyLayout noborder"></div>
    </div>
  </div>
</template>

<script>
import { dailyaddzlys, dailylistzlys } from "@/api/system/daily";
export default {
  data() {
    return {
      // 陕西海通零货条目数
      ids: null,
      systemTime: "",
      pytmTotal: undefined,
      pyjsTotal: undefined,
      zytmTotal: undefined,
      zyjsTotal: undefined,
      thtmTotal: undefined,
      thjsTotal: undefined,
      ycqktmTotal: undefined,
      jdpgsTotal: undefined,
      jdhsTotal: undefined,
      jdtmTotal: undefined,
      // 伟业
      reform: {
        rbSj: new Date().toISOString().split("T")[0],
        // 海通
        htPyTm: null,
        htPyJs: null,
        htZyTm: null,
        htZyJs: null,
        htThTm: null,
        htThJs: null,
        htYcqkTm: null,
        htJdysPgs: null,
        htJdysHs: null,
        htJdysTm: null,
        // 伟业
        wyPyTm: null,
        wyPyJs: null,
        wyZyTm: null,
        wyZyJs: null,
        wyThTm: null,
        wyThJs: null,
        wyYcqkTm: null,
        wyJdysPgs: null,
        wyJdysHs: null,
        wyJdysTm: null,
        // 其他
        qtPyTm: null,
        qtPyJs: null,
        qtZyTm: null,
        qtZyJs: null,
        qtThTm: null,
        qtThJs: null,
        qtYcqkTm: null,
        qtJdysPgs: null,
        qtJdysHs: null,
        qtJdysTm: null,
        // 时间
        htwyPyTime: "",
        htwyZyTime: "",
        qtPyTime: "",
        qtZyTime: "",
        thTime: "",
        jdTime: "",
      },
    };
  },
  mounted() {
    // 创建一个 Date 对象
    const currentDate = new Date();
    // 获取当前年份
    const year = currentDate.getFullYear();
    // 获取当前月份（注意：月份是从 0 开始计数的，所以需要加 1）
    const month = currentDate.getMonth() + 1;
    // 获取当前日期
    const day = currentDate.getDate();
    // 打印年月日
    this.systemTime = `${year}年${month}月${day}日`;
    this.getreTodayList();
  },
  beforeDestroy() {},
  methods: {
    addDecimals(...nums) {
      const precision = 1000000; // 保留六位小数
      const sum = nums.reduce(
        (acc, num) => acc + Math.round(num * precision),
        0
      );
      return sum / precision;
    },
    calculatepytmTotal() {
      this.pytmTotal = this.addDecimals(
        Number(this.reform.htPyTm),
        Number(this.reform.wyPyTm),
        Number(this.reform.qtPyTm)
      );
    },
    calculatepyjsTotal() {
      this.pyjsTotal = this.addDecimals(
        Number(this.reform.htPyJs),
        Number(this.reform.wyPyJs),
        Number(this.reform.qtPyJs)
      );
    },
    calculatezytmTotal() {
      this.zytmTotal = this.addDecimals(
        Number(this.reform.htZyTm),
        Number(this.reform.wyZyTm),
        Number(this.reform.qtZyTm)
      );
    },
    calculatezyjsTotal() {
      this.zyjsTotal = this.addDecimals(
        Number(this.reform.htZyJs),
        Number(this.reform.wyZyJs),
        Number(this.reform.qtZyJs)
      );
    },
    calculatethtmTotal() {
      this.thtmTotal = this.addDecimals(
        Number(this.reform.htThTm),
        Number(this.reform.wyThTm),
        Number(this.reform.qtThTm)
      );
    },
    calculatethjsTotal() {
      this.thjsTotal = this.addDecimals(
        Number(this.reform.htThJs),
        Number(this.reform.wyThJs),
        Number(this.reform.qtThJs)
      );
    },
    calculateycqktmTotal() {
      this.ycqktmTotal = this.addDecimals(
        Number(this.reform.htYcqkTm),
        Number(this.reform.wyYcqkTm),
        Number(this.reform.qtYcqkTm)
      );
    },
    calculatejspgsTotal() {
      this.jdpgsTotal = this.addDecimals(
        Number(this.reform.htJdysPgs),
        Number(this.reform.wyJdysPgs),
        Number(this.reform.qtJdysPgs)
      );
    },
    calculatejdhsTotal() {
      this.jdhsTotal = this.addDecimals(
        Number(this.reform.htJdysHs),
        Number(this.reform.wyJdysHs),
        Number(this.reform.qtJdysHs)
      );
    },
    calculatejdtmTotal() {
      this.jdtmTotal = this.addDecimals(
        Number(this.reform.htJdysTm),
        Number(this.reform.wyJdysTm),
        Number(this.reform.qtJdysTm)
      );
    },
    // 获取收货列表
    getreTodayList() {
      dailylistzlys().then((res) => {
        if (res.data) {
          this.reform = res.data;
          this.pytmTotal = this.addDecimals(
            Number(this.reform.htPyTm),
            Number(this.reform.wyPyTm),
            Number(this.reform.qtPyTm)
          );
          this.pyjsTotal = this.addDecimals(
            Number(this.reform.htPyJs),
            Number(this.reform.wyPyJs),
            Number(this.reform.qtPyJs)
          );
          this.zytmTotal = this.addDecimals(
            Number(this.reform.htZyTm),
            Number(this.reform.wyZyTm),
            Number(this.reform.qtZyTm)
          );
          this.zyjsTotal = this.addDecimals(
            Number(this.reform.htZyJs),
            Number(this.reform.wyZyJs),
            Number(this.reform.qtZyJs)
          );
          this.thtmTotal = this.addDecimals(
            Number(this.reform.htThTm),
            Number(this.reform.wyThTm),
            Number(this.reform.qtThTm)
          );
          this.thjsTotal = this.addDecimals(
            Number(this.reform.htThJs),
            Number(this.reform.wyThJs),
            Number(this.reform.qtThJs)
          );
          this.ycqktmTotal = this.addDecimals(
            Number(this.reform.htYcqkTm),
            Number(this.reform.wyYcqkTm),
            Number(this.reform.qtYcqkTm)
          );
          this.jdpgsTotal = this.addDecimals(
            Number(this.reform.htJdysPgs),
            Number(this.reform.wyJdysPgs),
            Number(this.reform.qtJdysPgs)
          );
          this.jdhsTotal = this.addDecimals(
            Number(this.reform.htJdysHs),
            Number(this.reform.wyJdysHs),
            Number(this.reform.qtJdysHs)
          );
          this.jdtmTotal = this.addDecimals(
            Number(this.reform.htJdysTm),
            Number(this.reform.wyJdysTm),
            Number(this.reform.qtJdysTm)
          );
        }
      });
    },
    saveZlysdaily() {
      dailyaddzlys(this.reform).then((res) => {
        console.log(res);
        this.$modal.msgSuccess("新增成功");
        this.getreTodayList();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.receiveContent {
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  ::v-deep .el-table__body-wrapper {
    border: 1px solid #181616;
  }
  .el-table--group::after,
  .el-table--border::after {
    background-color: #181616;
  }
  ::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
    background-color: transparent;
  }
  ::v-deep .el-input__inner {
    height: 65px;
    line-height: 65px;
    border: none;
    text-align: center;
    color: #000000;
    width: 100%;
  }
  ::v-deep .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
  ::v-deep .el-input--prefix .el-input__inner {
    border: none;
  }
  ::v-deep .el-table tr {
    height: 70px;
  }

  .receiveTitle {
    display: flex;
    align-items: center;
    .customerTitle {
      width: 100%;
      font-size: 24px;
      font-weight: 700;
      margin: 30px 0 40px 0;
    }
    ::v-deep .el-button--success {
      height: 36px;
    }
  }
  .qualitycheckheader {
    width: 100%;
    height: 140px;
    border: 1px solid #e7dfdf;
    background: #05a5ff;
    display: flex;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    justify-content: space-around;
    .customText {
      width: 10%;
      height: 140px;
      line-height: 140px;
      text-align: center;
      border-right: 1px solid #e7dfdf;
    }
    .delivery {
      width: 90%;
      display: flex;
      flex-direction: column;
      .deliveryTop {
        height: 50%;
        line-height: 70px;
        text-align: center;
        border-right: 1px solid #e7dfdf;
      }
      .deliveryBottom {
        height: 50%;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid #e7dfdf;
        color: #ffffff;
        div {
          height: 100%;
          line-height: 70px;
          text-align: center;
          border-right: 1px solid #e7dfdf;
        }
        .Overtime {
          width: 8%;
        }
        .noOvertime {
          width: 13%;
        }
      }
    }
  }
  .customExtra {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    .wyLayout {
      font-weight: 700;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .endtimetop {
      padding-top: 30px;
    }
    .endtimeCenter {
      padding-top: 70px;
    }
    .customText {
      width: 11.2%;
    }
    .customTextchild {
      width: 6.5%;
    }
    .overtime {
      width: 8%;
    }
    .customTextabnomal {
      width: 8%;
    }
    .testReport {
      width: 8%;
    }
    .noborder {
      border-right: none !important;
    }
  }
  .customExtraHj {
    background: #75d561;
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    ::v-deep .el-input.is-disabled .el-input__inner {
      background: #75d561;
      font-weight: 700;
      color: #ff4800;
      font-size: 18px;
    }
    .wyLayout {
      font-weight: 700;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .customText {
      width: 11.2%;
    }
    .customTextchild {
      width: 6.5%;
    }
    .overtime {
      width: 8%;
    }
    .customTextabnomal {
      width: 8%;
    }
    .testReport {
      width: 8%;
    }
    .noborder {
      border-right: none !important;
    }
  }
}
</style>